#include <stdlib.h>

#include "lib.h"

#include "slotguts.h"
#include "bl7guts.h"


enum WheelContents {
    BLANK,
    BAR1,
    BAR2,
    BAR3,
    SEVEN,
    BLSEVEN
};


enum SpinResult
{
	EVT_LOSER = 0,
	EVT_3BLANKS,
	EVT_ANY3BARS,
	EVT_3BAR1,
	EVT_3BAR2,
	EVT_3BAR3,
	EVT_ANY3SEVENS,
	EVT_3SEVENS,
	EVT_3BLSEVENS,
	NUMEVENTS
};

        
bool8 
BL7SlotGuts::isValidGuts()
{
    return getGutsId() == 400 ||
           getGutsId() == 401 ||
           getGutsId() == 402 ||
           getGutsId() == 403 ||
           getGutsId() == 404 ||
           getGutsId() == 405 ||
           getGutsId() == 406 ||
           getGutsId() == 407;
}

uint8
BL7SlotGuts::classifyStops(uint8* stops,uint8 bet, uint8 line)
{
	uint8 result = EVT_LOSER;

	// 3-in-a-row
	//


	if ( getIcon(0, stops[0])->iconid == getIcon(1, stops[1])->iconid &&
		getIcon(1, stops[1])->iconid == getIcon(2, stops[2])->iconid)
	{
		switch (getIcon(0, stops[0])->iconid)
		{
			case BLANK:
                result = EVT_3BLANKS;
                break;

			case BAR1:
                result = EVT_3BAR1;
                break;

			case BAR2:
                result = EVT_3BAR2;
                break;

			case BAR3:
                result = EVT_3BAR3;
                break;

			case SEVEN:
                result = EVT_3SEVENS;
                break;

			case BLSEVEN:
                result = EVT_3BLSEVENS;
                break;

			default:
				break;
		}
	}
	else
	{
		int i, bars = 0, sevens = 0;

		for (i = 0; i < getReelCount(); i++)
			switch ( getIcon(i, stops[i])->iconid )
			{
				case SEVEN:
				case BLSEVEN:
					++sevens;
					break;

				case BAR1:
                case BAR2:
				case BAR3:
					++bars;
					break;
				default:
					break;
			}

		if (bars == 3)
			result = EVT_ANY3BARS;
		else if (sevens == 3)
			result = EVT_ANY3SEVENS;
	}

	return result;
}

#ifdef DEBUGSPIN
void BL7SlotGuts::Debug_SetLoserStops( uint8* pStops )
{
	pStops[0] = 10;
	pStops[1] = 6;
	pStops[2] = 8;
}
#endif